package com.dj.msgtable.commom;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class TimeGet {

    public static String nowTimeSteing() {
        SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");//设置日期格式
        String date = df.format(new Date());// new Date()为获取当前系统时间，也可使用当前时间戳
        return date;
    }

    public static Date nowTimeDate() {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

        Date time = null;
        try {
            time = sdf.parse(sdf.format(new Date()));

        } catch (ParseException e) {

            e.printStackTrace();
        }

        return time;
    }

    public static Long nowTimeLong() {
        long tmp = new Date().getTime() / 1000;
        return tmp;
    }
}
